package com.xyzwps.harbor.handler.user;

import com.xyzwps.harbor.handler.validator.CommonValidators;
import com.xyzwps.harbor.handler.validator.StringValidators;
import com.xyzwps.harbor.handler.validator.Validatable;
import com.xyzwps.harbor.handler.validator.ValidationException;

import java.util.Objects;

class RegisterUserDto implements Validatable<RegisterUserDto> {
    private String username;
    private String password;
    private String password2;
    private String vcode;
    private String scope;

    @Override
    public RegisterUserDto validate() {
        CommonValidators.usernameVF.validate(username);
        CommonValidators.passwordVF.validate(password);
        if (Objects.equals(password, password2)) {
            throw new ValidationException("Double passwords are not equivalent." );
        }
        CommonValidators.vcodeVF.validate(vcode);
        StringValidators.notEmpty("scope cannot be empty." ).validate(scope);
        return this;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPassword2() {
        return password2;
    }

    public void setPassword2(String password2) {
        this.password2 = password2;
    }

    public String getVcode() {
        return vcode;
    }

    public void setVcode(String vcode) {
        this.vcode = vcode;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }
}
